$(function() {

});

// 开户银行
$(document).on('click', '#showPicker', function() {
    weui.picker(Config.bank, {
        className: 'custom-classname',
        container: 'body',
        defaultValue: ['招商银行'],
        onChange: function (result) {
            console.log(result)
        },
        onConfirm: function (result) {
            $('#showPicker').text(result[0].label);
            $('.card-bank').val(result[0].value);
        },
        id: 'singleLinePicker'
    });
});

$(document).on('click', '.encash-btn', function() {
    var params = {
        account: $.trim($('.card-account').val()),
        name: $.trim($('.card-name').val()),
        bank: $.trim($('.card-bank').val())
    }
    for(i in params) {
        if(params[i] == '') {
            weui.alert('请输入提现信息', function() {
            });
            return false;
        }
    }
    var loading = weui.loading('loading', {
        className: 'custom-classname'
    });
    var result = Model.user.encash({
        account: params.account,
        accountName: params.name,
        accountBank: params.bank
    });
    if (result.code) {
        Common.fn.formatOutput(result);
        loading.hide();
        return false;
    }
    weui.alert('提现申请已提交', function() {
        location.href = 'balance.html';
    });
    loading.hide();
});